import 'package:flutter/material.dart';

// 头像大小
double _imgSize = 60.0;

// 个人基础信息 组件
class UserBasicInfoWidget extends StatelessWidget {
  final bool? showNickName;
  const UserBasicInfoWidget({
    super.key,
    this.showNickName = false, // 是否显示微信昵称，默认不显示
  });

  @override
  Widget build(BuildContext context) {

    // 左侧头像
    Widget avatarWidget = ClipRRect(
      borderRadius: BorderRadius.circular(8.0),
      child: Image.network(
        'https://www.yjgygl.com/group1/avatar/20231103/13/55/4/f64a070a5593a8ed6e6a4829c4171c99',
        width: _imgSize,
        height: _imgSize,
        fit: BoxFit.cover,
      ),
    );

    // 文本样式提取
    TextStyle textStyle = const TextStyle(
      color: Colors.grey,
    );

    return Container(
      color: Colors.white,
      padding: const EdgeInsets.symmetric(vertical: 20),
      child: InkWell(
        child: Padding(
          padding: const EdgeInsets.fromLTRB(20, 0, 16, 20),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              avatarWidget, // 左侧头像
              const SizedBox(width: 10),
              Expanded(
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    const Text('前端没钱', style: TextStyle(fontSize: 20.0, fontWeight: FontWeight.w500)),
                    Visibility(
                      visible: showNickName!,
                      child: Column(
                        children: [
                          const SizedBox(height: 8.0),
                          Text('昵称：做门禁卡卡贴', style: textStyle),
                        ],
                      )
                    ),
                    const SizedBox(height: 8.0),
                    Text('微信号：wx_user_name', style: textStyle),
                    const SizedBox(height: 8.0),
                    Text('地区：江苏连云港', style: textStyle)
                  ],
                ),
              )
            ],
          ),
        ),
        onTap: () {
          Navigator.pushNamed(context, 'PersonInfoPage', arguments: {
            'test': '测试传参'
          });
        },
      ),
    );
  }
}
